#pragma once

#include "Headers.h"

namespace CinePerfil 
{
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	public ref class First_Menu : public System::Windows::Forms::Form
	{
	public:
		First_Menu()
		{
			InitializeComponent();
		}

	protected:
		~First_Menu()
		{
			if (components)
			{
				delete components;
			}
			delete account;
			delete database;
			delete accounts;
		}
	private: Account *account;
	private: vector<Account> *accounts;
	private: DataBase *database;
	private: System::Windows::Forms::Button^  FM_okButton;
	private: System::Windows::Forms::Label^  FM_userLabel;
	private: System::Windows::Forms::Label^  FM_passLabel;
	private: System::Windows::Forms::Label^  FM_confirmPassLabel;
	private: System::Windows::Forms::Label^  FM_errorLabel;
	private: System::Windows::Forms::TextBox^  FM_userTextBox;
	private: System::Windows::Forms::TextBox^  FM_passTextBox;
	private: System::Windows::Forms::TextBox^  FM_confirmPassTextBox;
	private: System::Windows::Forms::Panel^  FM_registerPainel;
	private: System::Windows::Forms::RadioButton^  FM_loginRadioButton;
	private: System::Windows::Forms::RadioButton^  FM_registerRadioButton;

	private: System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(First_Menu::typeid));
			this->FM_okButton = (gcnew System::Windows::Forms::Button());
			this->FM_userLabel = (gcnew System::Windows::Forms::Label());
			this->FM_passLabel = (gcnew System::Windows::Forms::Label());
			this->FM_confirmPassLabel = (gcnew System::Windows::Forms::Label());
			this->FM_errorLabel = (gcnew System::Windows::Forms::Label());
			this->FM_userTextBox = (gcnew System::Windows::Forms::TextBox());
			this->FM_passTextBox = (gcnew System::Windows::Forms::TextBox());
			this->FM_confirmPassTextBox = (gcnew System::Windows::Forms::TextBox());
			this->FM_registerPainel = (gcnew System::Windows::Forms::Panel());
			this->FM_loginRadioButton = (gcnew System::Windows::Forms::RadioButton());
			this->FM_registerRadioButton = (gcnew System::Windows::Forms::RadioButton());
			this->FM_registerPainel->SuspendLayout();
			this->SuspendLayout();
			// 
			// FM_okButton
			// 
			this->FM_okButton->Cursor = System::Windows::Forms::Cursors::Hand;
			this->FM_okButton->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_okButton->Location = System::Drawing::Point(242, 250);
			this->FM_okButton->Name = L"FM_okButton";
			this->FM_okButton->Size = System::Drawing::Size(150, 65);
			this->FM_okButton->TabIndex = 0;
			this->FM_okButton->Text = L"Ok";
			this->FM_okButton->UseVisualStyleBackColor = true;
			this->FM_okButton->Click += gcnew System::EventHandler(this, &First_Menu::FM_okButton_Click);
			// 
			// FM_userLabel
			// 
			this->FM_userLabel->AutoSize = true;
			this->FM_userLabel->BackColor = System::Drawing::Color::Transparent;
			this->FM_userLabel->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_userLabel->Location = System::Drawing::Point(220, 80);
			this->FM_userLabel->Name = L"FM_userLabel";
			this->FM_userLabel->Size = System::Drawing::Size(81, 20);
			this->FM_userLabel->TabIndex = 1;
			this->FM_userLabel->Text = L"Username:";
			// 
			// FM_passLabel
			// 
			this->FM_passLabel->AutoSize = true;
			this->FM_passLabel->BackColor = System::Drawing::Color::Transparent;
			this->FM_passLabel->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_passLabel->Location = System::Drawing::Point(223, 126);
			this->FM_passLabel->Name = L"FM_passLabel";
			this->FM_passLabel->Size = System::Drawing::Size(78, 20);
			this->FM_passLabel->TabIndex = 2;
			this->FM_passLabel->Text = L"Password:";
			// 
			// FM_confirmPassLabel
			// 
			this->FM_confirmPassLabel->AutoSize = true;
			this->FM_confirmPassLabel->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_confirmPassLabel->Location = System::Drawing::Point(34, 11);
			this->FM_confirmPassLabel->Name = L"FM_confirmPassLabel";
			this->FM_confirmPassLabel->Size = System::Drawing::Size(137, 20);
			this->FM_confirmPassLabel->TabIndex = 3;
			this->FM_confirmPassLabel->Text = L"Confirm Password:";
			// 
			// FM_errorLabel
			// 
			this->FM_errorLabel->BackColor = System::Drawing::Color::Transparent;
			this->FM_errorLabel->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_errorLabel->ForeColor = System::Drawing::Color::Red;
			this->FM_errorLabel->Location = System::Drawing::Point(75, 210);
			this->FM_errorLabel->Name = L"FM_errorLabel";
			this->FM_errorLabel->Size = System::Drawing::Size(500, 30);
			this->FM_errorLabel->TabIndex = 4;
			this->FM_errorLabel->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
			// 
			// FM_userTextBox
			// 
			this->FM_userTextBox->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_userTextBox->Location = System::Drawing::Point(305, 77);
			this->FM_userTextBox->Name = L"FM_userTextBox";
			this->FM_userTextBox->Size = System::Drawing::Size(150, 28);
			this->FM_userTextBox->TabIndex = 5;
			// 
			// FM_passTextBox
			// 
			this->FM_passTextBox->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_passTextBox->Location = System::Drawing::Point(305, 123);
			this->FM_passTextBox->Name = L"FM_passTextBox";
			this->FM_passTextBox->PasswordChar = '*';
			this->FM_passTextBox->Size = System::Drawing::Size(150, 28);
			this->FM_passTextBox->TabIndex = 6;
			// 
			// FM_confirmPassTextBox
			// 
			this->FM_confirmPassTextBox->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_confirmPassTextBox->Location = System::Drawing::Point(175, 8);
			this->FM_confirmPassTextBox->Name = L"FM_confirmPassTextBox";
			this->FM_confirmPassTextBox->PasswordChar = '*';
			this->FM_confirmPassTextBox->Size = System::Drawing::Size(150, 28);
			this->FM_confirmPassTextBox->TabIndex = 7;
			// 
			// FM_registerPainel
			// 
			this->FM_registerPainel->BackColor = System::Drawing::Color::Transparent;
			this->FM_registerPainel->Controls->Add(this->FM_confirmPassLabel);
			this->FM_registerPainel->Controls->Add(this->FM_confirmPassTextBox);
			this->FM_registerPainel->Location = System::Drawing::Point(130, 155);
			this->FM_registerPainel->Name = L"FM_registerPainel";
			this->FM_registerPainel->Size = System::Drawing::Size(374, 47);
			this->FM_registerPainel->TabIndex = 8;
			this->FM_registerPainel->Visible = false;
			// 
			// FM_loginRadioButton
			// 
			this->FM_loginRadioButton->AutoSize = true;
			this->FM_loginRadioButton->BackColor = System::Drawing::Color::Transparent;
			this->FM_loginRadioButton->Checked = true;
			this->FM_loginRadioButton->Cursor = System::Windows::Forms::Cursors::Hand;
			this->FM_loginRadioButton->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_loginRadioButton->Location = System::Drawing::Point(197, 25);
			this->FM_loginRadioButton->Name = L"FM_loginRadioButton";
			this->FM_loginRadioButton->Size = System::Drawing::Size(66, 27);
			this->FM_loginRadioButton->TabIndex = 9;
			this->FM_loginRadioButton->TabStop = true;
			this->FM_loginRadioButton->Text = L"Login";
			this->FM_loginRadioButton->UseVisualStyleBackColor = false;
			this->FM_loginRadioButton->CheckedChanged += gcnew System::EventHandler(this, &First_Menu::FM_loginRadioButton_CheckedChanged);
			// 
			// FM_registerRadioButton
			// 
			this->FM_registerRadioButton->AutoSize = true;
			this->FM_registerRadioButton->BackColor = System::Drawing::Color::Transparent;
			this->FM_registerRadioButton->Cursor = System::Windows::Forms::Cursors::Hand;
			this->FM_registerRadioButton->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->FM_registerRadioButton->Location = System::Drawing::Point(367, 25);
			this->FM_registerRadioButton->Name = L"FM_registerRadioButton";
			this->FM_registerRadioButton->Size = System::Drawing::Size(90, 27);
			this->FM_registerRadioButton->TabIndex = 10;
			this->FM_registerRadioButton->TabStop = true;
			this->FM_registerRadioButton->Text = L"Register";
			this->FM_registerRadioButton->UseVisualStyleBackColor = false;
			this->FM_registerRadioButton->CheckedChanged += gcnew System::EventHandler(this, &First_Menu::FM_registerRadioButton_CheckedChanged);
			// 
			// First_Menu
			// 
			this->AcceptButton = this->FM_okButton;
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"$this.BackgroundImage")));
			this->ClientSize = System::Drawing::Size(634, 337);
			this->Controls->Add(this->FM_registerRadioButton);
			this->Controls->Add(this->FM_loginRadioButton);
			this->Controls->Add(this->FM_errorLabel);
			this->Controls->Add(this->FM_registerPainel);
			this->Controls->Add(this->FM_passTextBox);
			this->Controls->Add(this->FM_userTextBox);
			this->Controls->Add(this->FM_passLabel);
			this->Controls->Add(this->FM_userLabel);
			this->Controls->Add(this->FM_okButton);
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
			this->MaximizeBox = false;
			this->MaximumSize = System::Drawing::Size(650, 375);
			this->MinimizeBox = false;
			this->MinimumSize = System::Drawing::Size(650, 375);
			this->Name = L"First_Menu";
			this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide;
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"CinePerfil - Authentication";
			this->Load += gcnew System::EventHandler(this, &First_Menu::First_Menu_Load);
			this->FM_registerPainel->ResumeLayout(false);
			this->FM_registerPainel->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private:
		Void load_accounts_file();
		Void load_data_base();
		Boolean verify_register(String^ username, String^ password, String^ confirmPassword);
		Boolean verify_login(String^ username, String^ password);		
		Int32 already_exists(String^ username);
		Void clear_textboxes(Boolean all);
		Void FM_registerRadioButton_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
		Void FM_loginRadioButton_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
		Void FM_okButton_Click(System::Object^  sender, System::EventArgs^  e);
		Void First_Menu_Load(System::Object^  sender, System::EventArgs^  e);
	};
}
